package com.egg.basic.controller.feign;

import com.egg.basic.fegin.BasicSecureFeignClient;
import com.egg.basic.service.secure.SecureService;
import com.egg.common.core.model.controller.FeignController;
import com.egg.common.core.model.response.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author east
 */
@Slf4j
@Api(tags = FeignController.API_PREFIX + "加解密")
@RestController
@RequestMapping("/secure")
public class FeignSecureController extends FeignController implements BasicSecureFeignClient {


    @Autowired
    private SecureService secureService;


    @Override
    @ApiOperation(value = "获取对称秘钥")
    @GetMapping("/aes")
    public ResponseData<String> aes(
            @ApiParam(value = "获取对称秘钥的KEY", required = true) @RequestParam(value = "secure") String secure
    ) {
        return ResponseData.success(secureService.findAesSecure(secure).orElse(null));
    }


}
